home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
shadez.swf
/
scripts
/
Local
/
Game
/
CGame.as
Wrap
Text File
|
2011-08-19
|
16KB
|
498 lines
package Local.Game
{
import Local.Audio.CAudio;
import Local.CGlobal;
import Local.CMain;
import Local.Draw.CWindow;
import Local.Draw.CWindow_Pause;
import Local.External.CKongregate;
import Local.Game.HUD.CHUD;
import Local.Game.Thing.CEffectExplosionLarge;
import Local.Game.Thing.CEffectExplosionMedium;
import Local.Game.Thing.CEffectExplosionSmall;
import Local.Game.Thing.CThingBase;
import Local.Game.World.CPosition;
import Local.Game.World.CWorld;
import Local.Math.CSecureNumber;
import STC9.IO.CKeyboard;
import STC9.System.CFrameSpeed;
import STC9.System.CProfiler;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
public class CGame extends Sprite
{
public static const GAME_DIED:String = "GAME_DIED";
public static const GAME_EXIT:String = "GAME_EXIT";
public static const GAME_COMPLETE:String = "GAME_COMPLETE";
public static var SECONDS:Number = 25;
{
if(true)
{
GAME_COMPLETE = "GAME_COMPLETE";
if(true)
{
GAME_EXIT = "GAME_EXIT";
GAME_DIED = "GAME_DIED";
}
SECONDS = 25;
}
}
private var mFadeOut:Bitmap;
public var mWorld:CWorld;
private var mInitialized:Boolean = false;
private var mFrameSpeed:CFrameSpeed;
public var mAudio:CAudio;
private var mKeyboard:CKeyboard;
public var mHUD:CHUD;
public var mPause:Boolean;
public var mTick:int;
public var mDisposed:Boolean;
private var mMain:CMain;
private var mPauseWindow:CWindow;
private var mGameCountOut:int;
public function CGame()
{
if(true)
{
mInitialized = false;
if(true)
{
super();
addEventListener(Event.ADDED_TO_STAGE,Initialize);
}
CGlobal.SetField("CHEATS",false);
}
}
private function ProcessFadeOut() : void
{
if(mFadeOut)
{
if((mFadeOut.alpha = mFadeOut.alpha - 0.05) < 0.05)
{
removeChild(mFadeOut);
mFadeOut.bitmapData.dispose();
mFadeOut = null;
mWorld.Start();
}
}
}
public function get mScore() : CSecureNumber
{
return mHUD.mFundsSecure;
}
public function Exit(param1:Event = null) : void
{
if(true)
{
dispatchEvent(new Event(GAME_EXIT));
}
}
public function Process() : void
{
var _loc1_:int = 0;
§§push(mInitialized);
if(true)
{
if(!§§pop())
{
return;
}
mWorld.mScrollDelta.x = (!!CKeyboard.IsDown("LEFT") ? -1 : (!!CKeyboard.IsDown("RIGHT") ? 1 : 0)) * (!!CKeyboard.IsDown("SHIFT") ? 100 : 20);
mWorld.mLandscape.Scroll(mWorld.mScrollDelta.x,mWorld.mScrollDelta.y);
CProfiler.StartProfile("Game.Process");
§§push(mHUD.mPlayState == "fast");
}
_loc1_ = !!§§pop() ? 10 : 1;
loop0:
while(true)
{
§§push(_loc1_);
while(true)
{
§§push(Boolean(§§pop()));
if(true)
{
if(§§pop())
{
if(true)
{
§§pop();
§§push(mDisposed);
}
§§push(!§§pop());
}
}
if(!§§pop())
{
break;
}
mWorld.Process();
mHUD.Process();
CheckGameState();
§§push(mTick);
if(true)
{
continue loop0;
}
}
mAudio.Update(mWorld.mLandscape.mWorldArea);
CProfiler.AddDebug("Game.Tick",String(mTick));
CProfiler.StopProfile("Game.Process");
return;
}
}
public function Resume(param1:Event = null) : void
{
mPause = false;
mKeyboard.Clear();
if(CGlobal.mSoundActive)
{
mAudio.Resume();
}
mHUD.Control_Play();
}
public function Draw() : void
{
if(!mInitialized)
{
return;
}
CProfiler.StartProfile("Game.Draw");
mWorld.Draw();
mHUD.Draw();
CProfiler.StopProfile("Game.Draw");
}
private function SetFadeOut(param1:DisplayObject) : void
{
if(true)
{
mFadeOut = new Bitmap(new BitmapData(CMain.mSize.width,CMain.mSize.height,false,0));
if(true)
{
mFadeOut.bitmapData.draw(param1);
}
mFadeOut.alpha = 1.1;
}
}
public function Initialize(param1:Event = null) : void
{
if(true)
{
removeEventListener(Event.ADDED_TO_STAGE,Initialize);
if(true)
{
mMain = CMain(parent);
if(true)
{
opaqueBackground = mMain.opaqueBackground;
if(true)
{
SetFadeOut(mMain);
if(true)
{
mInitialized = true;
if(true)
{
mTick = 0;
if(true)
{
mKeyboard = new CKeyboard(stage);
if(true)
{
mAudio = new CAudio();
if(true)
{
mHUD = new CHUD(this);
if(true)
{
addChild(mWorld = new CWorld(this));
if(true)
{
addChild(mHUD);
if(true)
{
mWorld.Initialise();
}
CGlobal.ResetLocalStats();
}
CGlobal.mStatsEnabled = false;
}
CProfiler.StartProfile("Game.Load");
}
new CEffectExplosionLarge(new CPosition()).Dispose();
}
new CEffectExplosionMedium(new CPosition()).Dispose();
}
new CEffectExplosionSmall(new CPosition()).Dispose();
}
CProfiler.StopProfile("Game.Load");
}
CGlobal.mStatsEnabled = true;
}
mFrameSpeed = new CFrameSpeed(25);
}
if(!mFadeOut)
{
}
§§goto(addr140);
}
addChild(mFadeOut);
}
addr140:
}
public function CheckGameState() : void
{
§§push(mTick);
if(true)
{
§§push(§§pop() % SECONDS);
§§push(0);
if(true)
{
if(§§pop() == §§pop())
{
if(mHUD.mFunds < 1000 && mWorld.mLevel.mFriendContainer.mNumChildren == 0 && !mHUD.mStrikesReady && !mHUD.mBuilding)
{
mHUD.mHealth = 0;
}
}
§§push(mHUD.mHealth);
§§push(0);
}
if(§§pop() <= §§pop())
{
Exit();
}
return;
}
§§goto(addr36);
}
public function Resize(param1:int, param2:int) : void
{
if(true)
{
mWorld.Resize(param1,param2);
}
}
public function Pause() : void
{
mPause = true;
var _loc1_:*;
mPauseWindow = _loc1_ = new CWindow_Pause(stage);
addChild(_loc1_);
§§push(mPauseWindow);
if(true)
{
§§push(CWindow.DISPOSING);
if(true)
{
§§pop().addEventListener(§§pop(),Resume);
addr40:
§§push(mPauseWindow);
§§push(CWindow_Pause.EXITGAME);
}
§§pop().addEventListener(§§pop(),Exit);
mAudio.Pause();
return;
}
§§goto(addr40);
}
public function Update() : void
{
if(true)
{
if(mDisposed)
{
if(true)
{
return;
}
addr151:
CProfiler.StopProfile("Game.Update");
}
else if(mPause)
{
if(true)
{
mPauseWindow.Update();
if(true)
{
§§goto(addr154);
}
else
{
addr137:
CProfiler.StartProfile("Game.Update");
}
§§goto(addr154);
}
Process();
Draw();
§§goto(addr151);
}
else
{
§§push(!mFadeOut);
if(!mFadeOut)
{
§§pop();
if(true)
{
§§push(Boolean(CKeyboard.IsReleased("P")));
if(!Boolean(CKeyboard.IsReleased("P")))
{
§§pop();
if(true)
{
addr50:
if(mHUD.mPlayState == "pause")
{
if(true)
{
Pause();
if(false)
{
addr125:
addr129:
if(CKeyboard.IsReleased("D"))
{
}
addr132:
if(mFrameSpeed.ProcessFrame())
{
addr135:
ProcessFadeOut();
§§goto(addr137);
}
}
§§goto(addr154);
}
CProfiler.ToggleMode();
§§goto(addr132);
}
else
{
if(CKeyboard.IsReleased("RETURN"))
{
if(true)
{
if(CKeyboard.CompareString("FUND"))
{
if(true)
{
mKeyboard.Clear();
if(true)
{
§§push(mHUD);
§§push(mHUD.mFunds);
if(true)
{
§§push(§§pop() + 1000000);
}
§§pop().mFunds = §§pop();
if(true)
{
CGlobal.SetField("CHEATS",true);
if(true)
{
CGlobal.SetField("HASCHEATED",true);
addr101:
if(!CKeyboard.CompareString("DEATH"))
{
}
addr118:
§§push(Boolean(CKeyboard.IsDown("SHIFT")));
if(Boolean(CKeyboard.IsDown("SHIFT")))
{
§§pop();
§§goto(addr125);
}
§§goto(addr129);
}
mKeyboard.Clear();
}
mWorld.mLevel.KillAllEnemies();
}
CGlobal.SetField("CHEATS",true);
}
CGlobal.SetField("HASCHEATED",true);
§§goto(addr118);
}
§§goto(addr101);
}
}
§§goto(addr101);
}
}
§§goto(addr125);
}
§§goto(addr50);
}
§§goto(addr135);
}
§§goto(addr50);
}
}
addr154:
}
public function Dispose() : void
{
if(true)
{
mWorld.Dispose();
if(true)
{
mAudio.Dispose();
if(true)
{
mHUD.Dispose();
if(true)
{
mKeyboard.Dispose();
}
mDisposed = true;
}
CGlobal.FlushStats();
}
CKongregate.UpdateStats();
}
}
}
}